package com.water.camera.kt

import com.snap.util.spGetInt
import com.snap.util.spPutInt

class FreeSizeUtil {

    companion object {
        // 送的次数
        fun getCurrentFreeSize(): Int = spGetInt(SpConstant.KEY_FREE_SIZE, 0)
        fun addFreeSize(size: Int) {
            val currentFreeSize = getCurrentFreeSize()
            spPutInt(SpConstant.KEY_FREE_SIZE, currentFreeSize + size)
        }

        fun isCanUse(): Boolean {
            val currentFreeSize = getCurrentFreeSize()
            return currentFreeSize > 0
        }

        fun useSize() {
            val currentFreeSize = getCurrentFreeSize()
            if (currentFreeSize == 0) return
            spPutInt(SpConstant.KEY_FREE_SIZE, currentFreeSize - 1)
        }
    }
}